<template>
	<zh-card :width="620">
		<template v-slot:title>
			<view style="border-left: 10rpx solid #2f54eb;">
				<zh-text  :fontSize="36" class="text-weight-b pl-10" label="基本信息"></zh-text>
			</view >
		</template>
		<template v-slot:content>
			<zh-form-input :disabled="true" field="fullName" :rules="[{required:true,message:'请输入学生姓名'}]" placeholder="请输入学生姓名" v-model="form.fullName" label="学生姓名" required :showClear="false" :transprent="true"></zh-form-input>
			<zh-form-select :disabled="true" :showClear="false"  field="cardType" :rules="[{required:true,message:'请选择学生证件类型'}]" placeholder="请选择学生证件类型" v-model="form.cardType" :options="data.dictData.cardType" label="学生证件类型" required  :transprent="true"></zh-form-select>
			<zh-form-input :disabled="true" field="idcard" :type="form.cardType==='01'?'idcard':'text'" :rules="[{required:true,message:'请输入学生证件号码'}]" placeholder="请输入学生证件号码" v-model="form.idcard" label="学生证件号码" required :showClear="false" :transprent="true"></zh-form-input>
			<zh-form-datetime :disabled="true" v-if="form.cardType!=='01'" field="birthYmd" :rules="[{required:true,message:'请输入学生出生日期'}]" placeholder="请输入学生出生日期" v-model="form.birthYmd"  label="出生日期" required :showClear="false" model="day" :transprent="true"></zh-form-datetime>
			<zh-form-select :disabled="true" v-if="form.cardType!=='01'" field="sex" :rules="[{required:true,message:'请选择学生性别'}]" placeholder="请选择学生性别" v-model="form.sex" :options="data.sexDict" label="性别" required :showClear="false" :transprent="true"></zh-form-select>
			<zh-form-input  field="address"  :height="90"   inputAlign="left"  :rules="[{required:true,message:'请输入学生现居住地'}]" placeholder="请输入学生现居住地" v-model="form.address" label="现居住地" type="textarea" required showClear :transprent="true"></zh-form-input>
			<zh-form-input  field="householdPlace" :height="90"   inputAlign="left"  :rules="[{required:true,message:'请输入学生户籍地'}]" placeholder="请输入学生户籍地" v-model="form.householdPlace" label="户籍地" type="textarea" required showClear :transprent="true"></zh-form-input>
			<zh-form-input :disabled="true" field="fatherName" :rules="[{required:false,message:'请输入父亲(监护人)姓名'}]" placeholder="请输入父亲(监护人)姓名" v-model="form.fatherName" label="父亲(监护人)姓名"  :showClear="false" :transprent="true"></zh-form-input>
			<zh-form-select :disabled="true" :showClear="false"  field="fatherCardType" :rules="[{required:false,message:'请输入父亲(监护人)证件类型'}]" placeholder="请输入父亲(监护人)证件类型" v-model="form.fatherCardType" :options="data.dictData.cardType" label="父亲(监护人)证件类型"  :transprent="true"></zh-form-select>
			<zh-form-input :disabled="true" field="fatherIdcard" :type="form.fatherCardType==='01'?'idcard':'text'" :rules="[{required:false,message:'请输入父亲(监护人)证件号码'}]" placeholder="请输入父亲(监护人)证件号码" v-model="form.fatherIdcard" label="父亲(监护人)身份证"  :showClear="false" :transprent="true"></zh-form-input>
			<zh-form-input field="fatherCellphone" :rules="[{required:false,message:'请输入父亲(监护人)手机'}]" number placeholder="请输入父亲(监护人)手机" v-model="form.fatherCellphone" label="父亲(监护人)手机"  showClear :transprent="true"></zh-form-input>
			<zh-form-input :disabled="true" field="motherName" :rules="[{required:false,message:'请输入母亲姓名'}]" placeholder="请输入母亲姓名" v-model="form.motherName" label="母亲姓名"  :showClear="false" :transprent="true"></zh-form-input>
			<zh-form-select :disabled="true" :showClear="false"  field="motherCardType" :rules="[{required:false,message:'请输入母亲证件类型'}]" placeholder="请输入母亲证件类型" v-model="form.motherCardType" :options="data.dictData.cardType" label="母亲证件类型"  :transprent="true"></zh-form-select>				
			<zh-form-input :disabled="true" field="motherIdcard" :type="form.motherCardType==='01'?'idcard':'text'" :rules="[{required:false,message:'请输入母亲证件号码'}]" placeholder="请输入母亲证件号码" v-model="form.motherIdcard" label="母亲证件号码"  :showClear="false" :transprent="true"></zh-form-input>
			<zh-form-input  field="motherCellphone" :rules="[{required:false,message:'请输入母亲手机'}]" type="number" placeholder="请输入母亲手机" v-model="form.motherCellphone" label="母亲手机"  showClear :transprent="true"></zh-form-input>
		</template>
	</zh-card>
</template>

<script lang="ts" setup>
	//学生基本信息
	import {reactive,watch,ref,onMounted} from "vue";
	// ------------------接收传入参数(组件)-------------------
	const props = defineProps({
		modelValue: {
		  type: Object,
		  default: () => {
			return {
				fullName:'',
				cardType:'01',
				motherCardType:'01',
				fatherCardType:'01',
			}
		}
		}
	})
	const emits = defineEmits([
	  "update:modelValue",
	]);
	//---------------内部变量--------------------
	const form=ref<any>(props.modelValue)
	const data = reactive({
		sexDict: [{
			dictKey: '1',
			dictValue: '男'
		}, {
			dictKey: '2',
			dictValue: '女'
		}],
		dictData:{} as any,//数据字典
		
		
	})
	//------------------初始化------------------------------
	onMounted(()=>{
	  getDict()
	})
	//-----------------------内部方法--------------------------------
	const getDict = () => {
		const params = {
			dictFields: 'cardType',
		};
		$api.common.getBatchDict.post(params).then((res: any) => {
			data.dictData = res.result;
		});
	
	};
	watch(
	  () => props.modelValue,
	  () => {
	   form.value=props.modelValue
	  },
	  {
	    deep:true
	  }
	  
	)
	
	watch(
		() => form.value,
		() => {
			//父组件发送数据
			emits("update:modelValue", form.value);
		},
		{
			deep: true,
		}
	);
</script>

<style lang="scss" scoped></style>